home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
7_3.lha
/
7_3
/
7_3c.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
1KB
|
78 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ exercise 7.3
undef line /* DELETE */
include <math.h>
lass circle: public shape
point center;
int radius;
ublic:
circle(point a, int r)
{
center = a; radius = r;
}
circle(point a, point b)
{
center = a;
radius = (int) sqrt((a.x - b.x) * (a.x - b.x) +
(a.y - b.y) * (a.y - b.y));
}
void move(int a, int b)
{
center.x += a;
center.y += b;
}
void draw();
point north()
{
return point(center.x + radius, center.y);
}
point south()
{
return point(center.x - radius, center.y);
}
point east()
{
return point(center.x, center.y + radius);
}
point west()
{
return point(center.x, center.y - radius);
}
point neast()
{
return point(center.x + radius,
center.y + radius);
}
point nwest()
{
return point(center.x - radius,
center.y + radius);
}
point seast()
{
return point(center.x - radius,
center.y + radius);
}
point swest()
{
return point(center.x - radius,
center.y - radius);
}
;